package cly.thirdpartyconsumer.task;

import cly.thirdpartyconsumer.service.DataSyncService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class DataSyncTask {


    @Autowired
    private DataSyncService dataSyncService;

    /**
     * 每天凌晨 3:00 执行
     */
    @Scheduled(cron = "0 * * * * ?")
    public void syncDataJob() {
        try {
            dataSyncService.syncAllData();
            System.out.println("💥 数据同步任务执行成功");
        } catch (Exception e) {
            System.out.println("💥 数据同步任务执行失败: " + e.getMessage());
        }
    }
}
